package model

import (
	"time"
)

type ReqOrderCreate struct {
	GoodsId int            `json:"goodsId" form:"goodsId"`
	GroupId int            `json:"groupId" form:"groupId"`
	BuyType int            `json:"buyType" form:"buyType"`
	Form    []ReqOrderForm `json:"form" form:"form" binding:"required" required_err:"请填写信息"`
}

type ReqOrderForm struct {
	Name  string      `json:"name" form:"name"`
	Value interface{} `json:"value" form:"value"`
}

type Order struct {
	Id              int            `xorm:"not null pk autoincr INT(10)" json:"id" form:"id"`
	Acid            int            `xorm:"" json:"acid" form:"acid"`
	UserId          int            `xorm:"" json:"user_id" form:"user_id"`
	Openid          string         `xorm:"" json:"openid" form:"openid"`
	GoodsId         int            `xorm:"" json:"goods_id" form:"goods_id"`
	GoodsTitle      string         `xorm:"" json:"goods_title" form:"goods_title"`
	GoodsPhoto      string         `xorm:"" json:"goods_photo" form:"goods_photo"`
	IsHead          int            `xorm:"" json:"is_head" form:"is_head"`
	HeadUserId      int            `xorm:"" json:"head_user_id" form:"head_user_id"`
	GroupId         int            `xorm:"" json:"group_id" form:"group_id"`
	GroupNum        int            `xorm:"" json:"group_num" form:"group_num"`
	GroupState      int            `xorm:"" json:"group_state" form:"group_state"`
	GroupMemberNum  int            `xorm:"" json:"group_member_num" form:"group_member_num"`
	OrderNo         string         `xorm:"" json:"order_no" form:"order_no"`
	Name            string         `xorm:"" json:"name" form:"name"`
	Phone           string         `xorm:"" json:"phone" form:"phone"`
	Nickname        string         `xorm:"" json:"nickname" form:"nickname"`
	Avatar          string         `xorm:"" json:"avatar" form:"avatar"`
	Form            []ReqOrderForm `xorm:"" json:"form" form:"form"`
	IsNewOld        string         `xorm:"" json:"is_new_old" form:"is_new_old"`
	PayAmount       float32        `xorm:"" json:"pay_amount" form:"pay_amount"`
	PayTime         int            `xorm:"" json:"pay_time" form:"pay_time"`
	PayState        int            `xorm:"" json:"pay_state" form:"pay_state"`
	HxState         int            `xorm:"" json:"hx_state" form:"hx_state"`
	HxTime          int            `xorm:"" json:"hx_time" form:"hx_time"`
	RefundState     int            `xorm:"" json:"refund_state" form:"refund_state"`
	RefundMsg       string         `xorm:"" json:"refund_msg" form:"refund_msg"`
	FromId          int            `xorm:"" json:"from_id" form:"from_id"`
	FromId2         int            `xorm:"" json:"from_id2" form:"from_id2"`
	StaffId         int            `xorm:"" json:"staff_id" form:"staff_id"`
	VerifierId      int            `xorm:"" json:"verifier_id" form:"verifier_id"`
	FailMsg         string         `xorm:"" json:"fail_msg" form:"fail_msg"`
	IsRobot         int            `xorm:"" json:"is_robot" form:"is_robot"`
	Address         string         `xorm:"" json:"address" form:"address"`
	CreatedAt       int            `xorm:"created" json:"created_at" form:"created_at"`
	UpdatedAt       int            `xorm:"updated" json:"updated_at" form:"updated_at"`
	DeletedAt       int            `xorm:"deleted" json:"deleted_at" form:"deleted_at"`
	Member          []Order        `xorm:"-" json:"member" form:"member"`
	HasBuy          int64          `xorm:"-" json:"has_buy" form:"has_buy"`
	Head            *Order         `xorm:"-" json:"head" form:"head"`
	ShareQrcodeUrl  string         `json:"share_qrcode_url" xorm:"-"`
	SubMchId        string         `xorm:"-" json:"sub_mch_id" form:"sub_mch_id"`
	TrackingNumber  string         `json:"tracking_number"`
	TrackingState   int            `json:"tracking_state"`
	TrackingCompany string         `json:"tracking_company"`
}

func (Order) TableName() string {
	return "order"
}

type ReqWithdrawal struct {
	Id           int       `json:"id"`
	Money        float32   `json:"money"  binding:"required" required_err:"参数缺失【money】"`
	Feel         float32   `json:"feel"`
	UserId       int       `json:"user_id"`
	State        int       `json:"state"`
	CreatedAt    time.Time `xorm:"created" json:"-"`
	UpdatedAt    time.Time `xorm:"updated" json:"-"`
	DeletedAt    time.Time `xorm:"deleted" json:"-"`
	Reason       string    `json:"reason"`
	FreezeAmount float32   `json:"freeze_amount"`
	SubMchId     string    `xorm:"-" json:"sub_mch_id" form:"sub_mch_id"`
}
type JoinWithdrawal struct {
	Id           int       `json:"id"`
	UserId       int       `json:"user_id"`
	Nickname     string    `json:"nickname"`
	Avatar       string    `json:"avatar"`
	Money        float32   `json:"money"`
	Feel         float32   `json:"feel"`
	State        int       `json:"state"` // 2申请 1 通过
	Reason       string    `json:"reason"`
	FreezeAmount float32   `json:"freeze_amount"`
	DeletedAt    time.Time `xorm:"deleted" json:"-"`
}
